package com.exception;

/**
 * @Author WaveHi
 * @Date 16/8/2021 下午 6:46
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description Throws关键字的使用
 */
public class TestThrows {

    public static void main(String[] args) {

        //获取测试数据
        int num1 = 10;
        int num2 = 0;

        try {
            //测试
            TestThrows.divide(num1,num2);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static int divide(int num1,int num2) throws RuntimeException{

        if(num2 == 0) {

            throw new RuntimeException("The divisor is zero.");

        }

        return num1 / num2;

    }

}
